package com.lc.job.jobhandle;

import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.context.XxlJobHelper;
import com.xxl.job.core.handler.annotation.XxlJob;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.util.concurrent.TimeUnit;

/**
 * @description: some desc
 * @author: LChuang
 * @date: 2023/10/7 15:08
 */
@Slf4j
@Component
public class MyXxlJob {

    @XxlJob("demoJob")
    public ReturnT<String> demoJob(String param) throws InterruptedException {
        // 使用XxlJobHelper输出日志会保存在日志文件中，日志路径在yml文件中配置
        XxlJobHelper.log("简单任务开始执行...");
        for (int i = 0; i < 5; i++) {
            XxlJobHelper.log("beat at:" + i);
            TimeUnit.SECONDS.sleep(2);
        }
        return ReturnT.SUCCESS;
    }

}
